home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / disk / misc / IDEID.lha / IDEID / IDEID.c next >
Encoding:
C/C++ Source or Header  |  1999-01-01  |  6.7 KB  |  179 lines

  1. /***************************************************************************/
  2. /*           IDE identify                                               OR */
  3. /* Compiler: SAS/C 6.57                                                    */
  4. /***************************************************************************/
  5. #include <exec/types.h>
  6. #include <exec/memory.h>
  7. #include <exec/io.h>
  8. #include <dos/rdargs.h>
  9. #include <proto/exec.h>
  10. #include <proto/dos.h>
  11.  
  12. struct IDData
  13. {
  14. UWORD id_Config;
  15. UWORD id_Cyls;
  16. UWORD id_Reserved1;
  17. UWORD id_Heads;
  18. UWORD id_TrackSize;
  19. UWORD id_SectorSize;
  20. UWORD id_SectorsPerTrack;
  21. UBYTE id_VendorUniq[6];
  22. UBYTE id_Serial[20];
  23. UWORD id_BufferType;
  24. UWORD id_BufferSize;
  25. UWORD id_ECC;
  26. UBYTE id_Revision[8];
  27. UBYTE id_Model[40];
  28. UWORD id_Mul;
  29. UWORD id_Doubleword;
  30. UWORD id_Capabilities;
  31. UWORD id_Reserved2;
  32. UWORD id_PIO;
  33. UWORD id_DMA;
  34. UWORD id_Fields;
  35. UWORD id_CurrentCyls;
  36. UWORD id_CurrentHeads;
  37. UWORD id_CurrentSectorsPerTrack;
  38. ULONG id_CurrentSectors;
  39. UBYTE id_Reserved3[394];
  40. };         // structure length is 512 bytes
  41.  
  42. struct IDData *iddata;
  43. struct MsgPort *devport;
  44. struct IOStdReq *devreq;
  45. struct RDArgs *rdargs;
  46. struct DosLibrary *DOSBase;
  47. enum   {ARG_UNIT,ARGCOUNT};
  48. LONG   myarray[ARGCOUNT];
  49. UBYTE  version[] ="$VER: IDEID 1.0 (01.04.99) (C) by OR\r\n";
  50.  
  51. LONG IDEID(VOID)
  52. {
  53. LONG  rc=ERROR_NOT_IMPLEMENTED;
  54. UBYTE *buffer1,*buffer2;
  55. ULONG i;
  56.  
  57.    if (DOSBase = (struct DosLibrary *)OpenLibrary("dos.library",39))
  58.    {
  59.    if (rdargs = ReadArgs("UNIT/A/N",&myarray[0],NULL))
  60.    {
  61.    if (!CheckSignal(SIGBREAKF_CTRL_C))
  62.    {
  63.    if (iddata = AllocVec(sizeof(struct IDData),MEMF_PUBLIC))
  64.    {
  65.    if (devport = CreateMsgPort())
  66.    {
  67.    if (devreq = CreateIORequest(devport,sizeof(struct IOStdReq)))
  68.    {
  69.    if (!OpenDevice("scsi.device",*(LONG *)myarray[ARG_UNIT],(struct IORequest *)devreq,NULL))
  70.    {
  71.  
  72.    buffer1 = (UBYTE *)devreq->io_Unit + 0x66;    // safe to read
  73.    buffer2 = (UBYTE *)iddata;
  74.    for (i=0; i < sizeof(struct IDData); i+=2) {*buffer2++ = *(buffer1+i+1);
  75.                                                *buffer2++ = *(buffer1+i);
  76.                                               }
  77.  
  78.    PutStr(  "Model number    = "); WriteChars(iddata->id_Model,sizeof(iddata->id_Model));
  79.    PutStr("\nRevision number = "); WriteChars(iddata->id_Revision,sizeof(iddata->id_Revision));
  80.    PutStr("\nSerial number   = "); WriteChars(iddata->id_Serial,sizeof(iddata->id_Serial));
  81.    PutStr("\n");
  82.  
  83.    if (iddata->id_Config & 0x8000) PutStr("Non magnetic media\n");
  84.                               else PutStr("Magnetic media\n");
  85.  
  86.    if (iddata->id_Config & 0x4000) PutStr("Format speed tolerance gap required\n");
  87.                               else PutStr("Format speed tolerance gap not required\n");
  88.  
  89.    if (iddata->id_Config & 0x2000) PutStr("Track offset option available\n");
  90.                               else PutStr("Track offset option not available\n");
  91.  
  92.    if (iddata->id_Config & 0x1000) PutStr("Data strobe offset option available\n");
  93.                               else PutStr("Data strobe offset option not available\n");
  94.  
  95.    if (iddata->id_Config & 0x0800) PutStr("Rotational speed tolerance is > 0.5%\n");
  96.                               else PutStr("Rotational speed tolerance is not > 0.5%\n");
  97.  
  98.    if (iddata->id_Config & 0x0400) PutStr("Disk transfer rate > 10 Mbs\n");
  99.    if (iddata->id_Config & 0x0200) PutStr("Disk transfer rate > 5 Mbs  but <= 10 Mbs\n");
  100.    if (iddata->id_Config & 0x0100) PutStr("Disk transfer rate <= 5 Mbs\n");
  101.  
  102.    if (iddata->id_Config & 0x0080) PutStr("Removable drive\n");
  103.    if (iddata->id_Config & 0x0040) PutStr("Fixed drive\n");
  104.  
  105.    if (iddata->id_Config & 0x0020) PutStr("Spindle motor control option implemented\n");
  106.                               else PutStr("Spindle motor control option not implemented\n");
  107.  
  108.    if (iddata->id_Config & 0x0010) PutStr("Head switch time > 15 usec\n");
  109.                               else PutStr("Head switch time not > 15 usec\n");
  110.  
  111.    if (iddata->id_Config & 0x0008) PutStr("Not MFM encoded\n");
  112.                               else PutStr("MFM encoded\n");
  113.  
  114.    if (iddata->id_Config & 0x0004) PutStr("Soft sectored\n");
  115.    if (iddata->id_Config & 0x0002) PutStr("Hard sectored\n");
  116.  
  117.    if (iddata->id_Doubleword) PutStr("Can perform doubleword I/O\n");
  118.                          else PutStr("Cannot perform doubleword I/O\n");
  119.  
  120.    if (iddata->id_BufferType == 0x0000) PutStr("Buffer type not specified\n");
  121.    if (iddata->id_BufferType == 0x0001) PutStr("single ported single sector buffer which is not capable of simultaneous data transfers to or from the host and the disk\n");
  122.    if (iddata->id_BufferType == 0x0002) PutStr("Dual ported multi-sector buffer capable of simultaneous data transfers to or from the host and the disk\n");
  123.    if (iddata->id_BufferType == 0x0003) PutStr("Dual ported multi-sector buffer capable of simultaneous transfers with a read caching capability\n");
  124.  
  125.    i = iddata->id_BufferSize*512; VPrintf("Buffer size = %lu\n",&i);
  126.  
  127.    i = iddata->id_ECC; VPrintf("Number of ECC bytes passed on Read/Write long cmds = %lu\n",&i);
  128.  
  129.    i = iddata->id_Mul & 0x00FF; VPrintf("Maximum number of sectors that can be transferred per interrupt on Read and Write Multiple commands = %lu\n",&i);
  130.  
  131.    i = iddata->id_TrackSize; VPrintf("Unformatted track size = %lu\n",&i);
  132.    i = iddata->id_SectorSize; VPrintf("Unformatted sector size = %lu\n",&i);
  133.  
  134.    if (iddata->id_Fields & 0x0001) PutStr("The fields reported in translation mode are valid\n");
  135.                               else PutStr("The fields reported in translation mode may be valid\n");
  136.  
  137.    PutStr("Default capacity (cylinders,heads,sectors per track)               =");
  138.    i = iddata->id_Cyls; VPrintf(" %lu",&i);
  139.    i = iddata->id_Heads; VPrintf(" %lu",&i);
  140.    i = iddata->id_SectorsPerTrack; VPrintf(" %lu\n",&i);
  141.  
  142.    PutStr("Translation mode (cylinders,heads,sectors per track,total sectors) =");
  143.    i = iddata->id_CurrentCyls; VPrintf(" %lu",&i);
  144.    i = iddata->id_CurrentHeads; VPrintf(" %lu",&i);
  145.    i = iddata->id_CurrentSectorsPerTrack; VPrintf(" %lu",&i);
  146.    i = iddata->id_CurrentSectors; i = (i<<16) | (i>>16); VPrintf(" %lu\n",&i);
  147.  
  148.    if (iddata->id_Capabilities & 0x0100) PutStr("DMA supported\n");
  149.                                     else PutStr("DMA not supported\n");
  150.  
  151.    i = iddata->id_PIO >> 8; VPrintf("PIO data transfer cycle timing mode = %lu\n",&i);
  152.  
  153.    i = iddata->id_DMA >> 8; VPrintf("DMA data transfer cycle timing mode = %lu\n",&i);
  154.  
  155.    rc = RETURN_OK;
  156.    CloseDevice((struct IORequest *)devreq);
  157.    } else rc=ERROR_NO_DISK;
  158.  
  159.    DeleteIORequest(devreq);
  160.    }
  161.  
  162.    DeleteMsgPort(devport);
  163.    }
  164.  
  165.    FreeVec(iddata);
  166.    } else rc=ERROR_NO_FREE_STORE;
  167.  
  168.    } else rc=ERROR_BREAK;
  169.  
  170.    FreeArgs(rdargs);
  171.    } else rc=IoErr();
  172.   
  173.    if (rc) PrintFault(rc,NULL);
  174.    CloseLibrary((struct Library *)DOSBase);
  175.    }
  176.  
  177.    return(rc);
  178. }
  179.